package com.ly.lypopupwindowdemo.views;

import android.app.Activity;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.ly.lypopupwindowdemo.R;

/**
 * Created by liying on 2017/5/18.
 * 自定义View学习之二
 * 组合控件
 *
 */

public class TitleView extends FrameLayout {

    private Button back;
    private TextView title;

    public TitleView(@NonNull final Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);

        LayoutInflater.from(context).inflate(R.layout.base_title,this);
        back = (Button) findViewById(R.id.button_left);
        title = (TextView) findViewById(R.id.title_text);

        back.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((Activity) getContext()).finish();
            }
        });
    }


    public void setTitleText(String titleStr){
        title.setText(titleStr);
    }

    public void setLeftButtonText(String text){
        back.setText(text);
    }


    public void setLeftButtonListener(OnClickListener l) {
        back.setOnClickListener(l);
    }





}
